(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 11.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[     50803,       1167]
NotebookOptionsPosition[     47992,       1066]
NotebookOutlinePosition[     48429,       1085]
CellTagsIndexPosition[     48386,       1082]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell["Project Euler 11-20", "Title",
 CellChangeTimes->{
  3.825800593745206*^9, {3.8258267064566298`*^9, 3.82582670814363*^9}},
 TextAlignment->Center],

Cell[CellGroupData[{

Cell["\[FilledSquare]11. Largest product in a grid", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}}],

Cell["\<\
In the 20\[Times]20 grid below, four numbers along a diagonal line have been \
marked in red.
The product of these numbers is 26 \[Times] 63 \[Times] 78 \[Times] 14 = \
1788696.
What is the greatest product of four adjacent numbers in the same direction \
(up, down, left, right, or diagonally) in the 20\[Times]20 grid?\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{
  "string20by20", " ", "=", " ", "\n", 
   "\"\<08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08\n 49 49 \
99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00\n 81 49 31 73 55 79 14 \
29 93 71 40 67 53 88 30 03 49 13 36 65\n 52 70 95 23 04 60 11 42 69 24 68 56 \
01 32 56 71 37 02 36 91\n 22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 \
33 13 80\n 24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50\n 32 \
98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70\n 67 26 20 68 02 62 \
12 20 95 63 94 39 63 08 40 91 66 49 94 21\n 24 55 58 05 66 73 99 26 97 17 78 \
78 96 83 14 88 34 89 63 72\n 21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 \
34 31 33 95\n 78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92\n \
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57\n 86 56 00 48 35 \
71 89 07 05 44 44 37 44 60 21 58 51 54 17 58\n 19 80 81 68 05 94 47 69 28 73 \
92 13 86 52 17 77 04 89 55 40\n 04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 \
79 33 27 98 66\n 88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69\n\
 04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36\n 20 69 36 41 72 \
30 23 88 34 62 99 69 82 67 59 85 74 04 36 16\n 20 73 35 29 78 31 90 01 74 31 \
49 71 48 86 81 16 23 57 05 54\n 01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 \
01 89 19 67 48\>\""}], ";"}]], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", 
   RowBox[{"String", " ", "to", " ", "Integer", " ", "matrix"}], "*)"}], "\n", 
  RowBox[{
   RowBox[{
    RowBox[{"matrix20by20", " ", "=", " ", 
     RowBox[{
      RowBox[{"Partition", "[", 
       RowBox[{
        RowBox[{"StringSplit", "[", "string20by20", "]"}], ",", "20"}], "]"}],
       "//", "ToExpression"}]}], ";"}], "\n", 
   RowBox[{"(*", 
    RowBox[{
     RowBox[{
      RowBox[{
       RowBox[{"Partition", "[", 
        RowBox[{"#", ",", "4", ",", "1"}], "]"}], "&"}], " ", "/@", " ", 
      "matrix20by20"}], "  ", "or", " ", "write", " ", "like", " ", "this"}], 
    "*)"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"matrix20by20", " ", "//", 
       RowBox[{
        RowBox[{"Map", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Partition", "[", 
            RowBox[{"#", ",", "4", ",", "1"}], "]"}], " ", "&"}], ",", "#"}], 
         "]"}], "&"}]}], " ", "//", 
      RowBox[{
       RowBox[{"Flatten", "[", 
        RowBox[{"#", ",", "1"}], "]"}], "&"}]}], " ", "//", 
     RowBox[{
      RowBox[{"Times", " ", "@@@", " ", "#"}], "&"}]}], "//", "Max"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{
       RowBox[{"Transpose", "[", "matrix20by20", "]"}], "//", 
       RowBox[{
        RowBox[{"Map", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Partition", "[", 
            RowBox[{"#", ",", "4", ",", "1"}], "]"}], " ", "&"}], ",", "#"}], 
         "]"}], "&"}]}], " ", "//", 
      RowBox[{
       RowBox[{"Flatten", "[", 
        RowBox[{"#", ",", "1"}], "]"}], "&"}]}], " ", "//", 
     RowBox[{
      RowBox[{"Times", " ", "@@@", " ", "#"}], "&"}]}], "//", "Max"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{
       RowBox[{
        RowBox[{
         RowBox[{"Diagonal", "[", 
          RowBox[{"matrix20by20", ",", "#"}], "]"}], "&"}], " ", "/@", " ", 
        RowBox[{"Range", "[", 
         RowBox[{
          RowBox[{"-", "19"}], ",", "19"}], "]"}]}], " ", "//", 
       RowBox[{
        RowBox[{"Map", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Partition", "[", 
            RowBox[{"#", ",", "4", ",", "1"}], "]"}], " ", "&"}], ",", "#"}], 
         "]"}], "&"}]}], " ", "//", 
      RowBox[{
       RowBox[{"Flatten", "[", 
        RowBox[{"#", ",", "1"}], "]"}], "&"}]}], " ", "//", 
     RowBox[{
      RowBox[{"Times", " ", "@@@", " ", "#"}], "&"}]}], "//", "Max"}], "\n", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{
       RowBox[{
        RowBox[{
         RowBox[{"Diagonal", "[", 
          RowBox[{
           RowBox[{"Reverse", "@", "matrix20by20"}], ",", "#"}], "]"}], "&"}],
         " ", "/@", " ", 
        RowBox[{"Range", "[", 
         RowBox[{
          RowBox[{"-", "19"}], ",", "19"}], "]"}]}], " ", "//", 
       RowBox[{
        RowBox[{"Map", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Partition", "[", 
            RowBox[{"#", ",", "4", ",", "1"}], "]"}], " ", "&"}], ",", "#"}], 
         "]"}], "&"}]}], " ", "//", 
      RowBox[{
       RowBox[{"Flatten", "[", 
        RowBox[{"#", ",", "1"}], "]"}], "&"}]}], " ", "//", 
     RowBox[{
      RowBox[{"Times", " ", "@@@", " ", "#"}], "&"}]}], "//", 
    "Max"}]}]}]], "Code",
 CellChangeTimes->CompressedData["
1:eJxTTMoPSmViYGAQBWIQ/Wvx64NKjW8c3zNVHgXRU5VVGvSB9DmLwiYQfaX0
4FQQfesU10wQPeXq3TkgeoFm4hIQXcJgP80ASKc77pgDokujrFeBaNuW22tA
dMv1jfdBdMfdnocg2io56iOIXnN6/2cQLbx5kXsZkF6xeIUfiDZbbtIIov2W
/2gB0T+mMveA6AtHE+aAaJfjmUtAtFfllh0gWrVo7QEQ/U4m9wKIVjq4V7sc
SN9tPQSmw5R/mYHoGQxzzUE0v8QhbxCt9MzZB0Tns4RfA8tPM7kPotXYi36C
6KKjp5kqgLTFrM1CIFqlcrk4iBbrdrUH0QdX2LiD5W1sA0E0x8mfwSAaABy1
q30=
  "]],

Cell[BoxData["48477312"], "Output",
 CellChangeTimes->{
  3.8259736412451572`*^9, 3.825973872585289*^9, {3.825974993526372*^9, 
   3.8259750343584547`*^9}, {3.8259752417401905`*^9, 3.825975246346651*^9}, {
   3.8259752961206284`*^9, 3.82597529704172*^9}, 3.8259754873137455`*^9, {
   3.825975847257736*^9, 3.8259758670817184`*^9}, 3.825975970063016*^9, 
   3.8270138673421497`*^9}],

Cell[BoxData["51267216"], "Output",
 CellChangeTimes->{
  3.8259736412451572`*^9, 3.825973872585289*^9, {3.825974993526372*^9, 
   3.8259750343584547`*^9}, {3.8259752417401905`*^9, 3.825975246346651*^9}, {
   3.8259752961206284`*^9, 3.82597529704172*^9}, 3.8259754873137455`*^9, {
   3.825975847257736*^9, 3.8259758670817184`*^9}, 3.825975970063016*^9, 
   3.82701386734615*^9}],

Cell[BoxData["40304286"], "Output",
 CellChangeTimes->{
  3.8259736412451572`*^9, 3.825973872585289*^9, {3.825974993526372*^9, 
   3.8259750343584547`*^9}, {3.8259752417401905`*^9, 3.825975246346651*^9}, {
   3.8259752961206284`*^9, 3.82597529704172*^9}, 3.8259754873137455`*^9, {
   3.825975847257736*^9, 3.8259758670817184`*^9}, 3.825975970063016*^9, 
   3.8270138673481503`*^9}],

Cell[BoxData["70600674"], "Output",
 CellChangeTimes->{
  3.8259736412451572`*^9, 3.825973872585289*^9, {3.825974993526372*^9, 
   3.8259750343584547`*^9}, {3.8259752417401905`*^9, 3.825975246346651*^9}, {
   3.8259752961206284`*^9, 3.82597529704172*^9}, 3.8259754873137455`*^9, {
   3.825975847257736*^9, 3.8259758670817184`*^9}, 3.825975970063016*^9, 
   3.827013867354151*^9}]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]12. Highly divisible triangular number", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}}],

Cell["\<\
The sequence of triangle numbers is generated by adding the natural numbers. \
So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first \
ten terms would be:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
Let us list the factors of the first seven triangle numbers:
     1: 1
     3: 1,3
     6: 1,2,3,6
    10: 1,2,5,10
    15: 1,3,5,15
    21: 1,3,7,21
    28: 1,2,4,7,14,28
We can see that 28 is the first triangle number to have over five divisors.
What is the value of the first triangle number to have over five hundred \
divisors?\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", 
   RowBox[{
   "DivisorSigma\:53ef\:4ee5\:9ad8\:6548\:8ba1\:7b97\:9664\:6570\:4e2a\:6570\
\:7b2c\:4e00\:4e2a\:53c2\:6570\:8868\:793a\:9664\:6570\:7684\:51e0\:6b21\:65b9\
", "\:ff0c", "\:8fd4\:56de\:4ed6\:4eec\:7684\:548c", "\:3002", 
    RowBox[{"\:7528\:6765\:66ff\:4ee3Length", "@", 
     RowBox[{"Divisors", "[", "20", "]"}]}]}], "*)"}], "\n", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"HighlyDivisible", "[", "max_", "]"}], ":=", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"n", " ", "=", " ", "1"}], "}"}], ",", "\n", 
       RowBox[{
        RowBox[{"While", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"DivisorSigma", "[", 
            RowBox[{"0", ",", 
             FractionBox[
              RowBox[{"n", 
               RowBox[{"(", 
                RowBox[{"n", "+", "1"}], ")"}]}], "2"]}], "]"}], "<", "max"}],
           ",", 
          RowBox[{"n", "++"}]}], "]"}], ";", "\n", 
        FractionBox[
         RowBox[{"n", 
          RowBox[{"(", 
           RowBox[{"n", "+", "1"}], ")"}]}], "2"]}]}], "]"}]}], ";"}], "\n", 
   RowBox[{"HighlyDivisible", "[", "500", "]"}]}]}]], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.8259851311800637`*^9, 
   3.8259852408470297`*^9}, {3.8259852776537094`*^9, 3.825985309607905*^9}}],

Cell[BoxData["76576500"], "Output",
 CellChangeTimes->{{3.825985302570201*^9, 3.825985310198964*^9}, 
   3.8270138674651623`*^9}]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]13. Large sum", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.8259835475427065`*^9, 
   3.825983549389891*^9}}],

Cell["Too simple to calculate, the answer is 5537376230", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259841283607826`*^9, 
   3.825984174693415*^9}}]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]14. Longest Collatz sequence", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.825984319880933*^9, 
   3.8259843237983246`*^9}}],

Cell["\<\
The following iterative sequence is defined for the set of positive integers:
n \[RightArrow] n/2 (n is even)
n \[RightArrow] 3n + 1 (n is odd)
Using the rule above and starting with 13, we generate the following sequence:
13 \[RightArrow] 40 \[RightArrow] 20 \[RightArrow] 10 \[RightArrow] 5 \
\[RightArrow] 16 \[RightArrow] 8 \[RightArrow] 4 \[RightArrow] 2 \
\[RightArrow] 1
It can be seen that this sequence (starting at 13 and finishing at 1) \
contains 10 terms. Although it has not been proved yet (Collatz Problem), it \
is thought that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
NOTE: Once the chain starts the terms are allowed to go above one million.\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259843286908135`*^9, 
   3.8259843408320274`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"CollatzSequence", "[", "n_", "]"}], ":=", " ", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"temp", " ", "=", " ", "n"}], ",", 
       RowBox[{"result", " ", "=", " ", "0"}]}], "}"}], ",", "\n", "\t", 
     RowBox[{
      RowBox[{"While", "[", 
       RowBox[{
        RowBox[{"temp", " ", "\[NotEqual]", " ", "1"}], ",", 
        RowBox[{
         RowBox[{"result", "+=", "1"}], ";", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"EvenQ", "[", "temp", "]"}], ",", 
           RowBox[{"temp", " ", "=", " ", 
            RowBox[{"temp", "/", "2"}]}], ",", 
           RowBox[{"temp", " ", "=", " ", 
            RowBox[{
             RowBox[{"3", "*", "temp"}], "+", "1"}]}]}], "]"}]}]}], "]"}], 
      ";", "\n", "\t", 
      RowBox[{"result", "+", "1"}]}]}], "\n", "]"}]}], ";"}], "\n", 
 RowBox[{
  RowBox[{
   RowBox[{"MaxCollatz", "[", "size_", "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"result", " ", "=", " ", "0"}], ",", 
       RowBox[{"temp", " ", "=", " ", "0"}], ",", 
       RowBox[{"num", " ", "=", " ", "0"}]}], "}"}], ",", "\n", 
     RowBox[{
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", " ", "=", " ", "1"}], ",", " ", 
        RowBox[{"i", " ", "<", " ", "size"}], ",", " ", 
        RowBox[{"i", "++"}], ",", "\n", 
        RowBox[{
         RowBox[{"temp", " ", "=", " ", 
          RowBox[{"CollatzSequence", "[", "i", "]"}]}], ";", " ", "\n", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"result", " ", "<", " ", "temp"}], ",", 
           RowBox[{
            RowBox[{"result", " ", "=", " ", "temp"}], ";", " ", 
            RowBox[{"num", " ", "=", " ", "i"}]}]}], "]"}]}]}], "]"}], ";", 
      "\n", 
      RowBox[{"{", 
       RowBox[{"num", ",", "result"}], "}"}]}]}], "\n", "]"}]}], ";"}], "\n", 
 RowBox[{
  RowBox[{
   RowBox[{"MaxCollatzScan", "[", "size_", "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"result", "=", "0"}], "}"}], ",", "\n", 
     RowBox[{
      RowBox[{"Scan", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"result", "<", 
            RowBox[{"CollatzSequence", "[", "#", "]"}]}], ",", 
           RowBox[{"result", " ", "=", " ", "#"}]}], "]"}], " ", "&"}], ",", 
        RowBox[{"Range", "[", "size", "]"}]}], "]"}], ";", "\n", "result"}]}],
     "\n", "]"}]}], ";"}], "\n", 
 RowBox[{
  RowBox[{"MaxCollatzScan", "[", "10000", "]"}], "//", 
  "AbsoluteTiming"}], "\n", 
 RowBox[{
  RowBox[{"MaxCollatz", "[", "10000", "]"}], "//", 
  "AbsoluteTiming"}]}], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.82598433075602*^9, 3.8259843326812124`*^9}, {
   3.8259846976180735`*^9, 3.8259848486700735`*^9}, {3.8259853356165056`*^9, 
   3.8259854803599787`*^9}, {3.825985513039246*^9, 3.8259859767446117`*^9}, {
   3.8259860201459513`*^9, 3.825986028486786*^9}, {3.825986533072239*^9, 
   3.8259865385197835`*^9}, {3.825986585439475*^9, 3.8259867377887087`*^9}, {
   3.825987071597086*^9, 3.825987112588185*^9}, {3.8259871457855043`*^9, 
   3.82598724525245*^9}, 3.825987874354354*^9, {3.825988256832056*^9, 
   3.825988284403056*^9}, {3.825988325538056*^9, 3.825988337872056*^9}, {
   3.82598924276019*^9, 3.8259893025111647`*^9}, {3.825989347262639*^9, 
   3.825989415348447*^9}, {3.825989535096421*^9, 3.8259896330732174`*^9}, {
   3.8259896791318226`*^9, 3.8259897571796265`*^9}, {3.825989832184127*^9, 
   3.8259901532332287`*^9}, {3.825990296691573*^9, 3.8259905787677774`*^9}, {
   3.8259909505469513`*^9, 3.825990995374434*^9}, {3.825991073800276*^9, 
   3.8259910770305986`*^9}, {3.8259911124161367`*^9, 3.8259913504229355`*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"1.9633188310719436`", ",", "313"}], "}"}]], "Output",
 CellChangeTimes->{
  3.82599051368427*^9, 3.825990996100507*^9, 3.8259910822271185`*^9, {
   3.825991134028298*^9, 3.8259913528421774`*^9}, 3.8270138694493604`*^9}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"1.9903090631633877`", ",", 
   RowBox[{"{", 
    RowBox[{"6171", ",", "262"}], "}"}]}], "}"}]], "Output",
 CellChangeTimes->{
  3.82599051368427*^9, 3.825990996100507*^9, 3.8259910822271185`*^9, {
   3.825991134028298*^9, 3.8259913528421774`*^9}, 3.827013871439559*^9}]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]15. Lattice paths", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.825984319880933*^9, 
   3.8259843237983246`*^9}, {3.8259919776570387`*^9, 3.825991986562039*^9}}],

Cell[TextData[{
 "Starting in the top left corner of a 2\[Times]2 grid, and only being able \
to move to the right and down, there are exactly 6 routes to the bottom right \
corner.\n",
 Cell[BoxData[
  GraphicsBox[
   TagBox[RasterBox[CompressedData["
1:eJztnE2KlFkQRQvtgUO34C6c9tCp4gIUq6VBSigFcSVuq3fU5jgxK/N7Ee/G
3xGuoIjx3fPuceirj1/f/vPs7u7u24vTT28//Pj78fHDz3cvT794//Dt388P
95/ePHy//3z/+Prj89Nv/jrlv1P+OuXL3T1ZzOnH/4pE94RXnm6dGHbrA68a
3brwi+5YiVUnXn9iFv09FXfRoYuCUydel5hFb70awy57wB8/fxT8lO9TuU9X
f6rzutSj+t7UDLvsAX98elTfm5phlz3gj0+P6ntTM+yyB/zx6VF9b2qGXfaA
Pz49qu9NzbDLHvDHp0f1vakZdtkD/vj0qL43NcMue8Afnx7V96Zm2GUP+OPT
o/re1Ay77AF/fHpU35uaYZc94I9Pj+p7UzPssgf88elRfW9qhl32gD8+Parv
Tc2wyx7wx6dH9b2pGXbZA/749Ki+NzXDLnvAH58e1femZthlD/jj06P63tQM
u+wBf3x6VN+bmmGXPeCPT4/qe1Mz7LIH/PHpUX1vaoZd9oA/Pj2q703NsMse
8MenR/W9qRmq97AzuzlF8FL3qL43NUP1HvAnz9tf8qf6W0X40yFKfzp0uuQP
DO0cK3KCl52V0h8Vw05d8CfP2+NP/i7wytsFf/J3gVfeLviTvwu88nbBn/xd
4JW3C/7k7wKvvF0q+3POyZLoLvDy5YQ/2k1k6AIvP074o9tDli7w8uOEP7pN
ZOoCL/9+6jeZ5E+2LvDy76d+k2r+WDaRsQu8fLup32SKP1m7wMu3m/pNKvqz
sonMXeDl10v9JhP8yd4FXn691G9S1Z8jm6jQBV4+ndRv0t2fKl3g5dNJ/Sb4
k6MLvHw6PfVndvSo7M+1TVTrAi97n9U/s9oDf/J0gZe9z5HOHj2q+3OJT9Uu
8LJ1ubXvSnf8yd8FXrYut/ZdYdDVn3NG1bvAa62H1Z9rPPCnRhd4rfXw8ufS
3zXBnw5d4HW8x8481UNxXxnVHroEXvl4EaIO/hCyHtwhZE/whpD14A0h68Eb
QtaDN4SsB28IWQ/eELIevCFkPXhDCCGEEEIIIYQQQgghhBBCCCGEEEIIIYQQ
QgghhBBCCCGE3BbF/9eoDszgpWKmZKl6K/UeqneB1/od/Jm9B3jZ7uDP7D3A
y3YHf2bvAV62O/gzew/wst3Bn9l7gJftDv7M3gO8bHfwZ/Ye4GW7gz+z9wAv
2x38mb0HeNnu4M/sPcDLdgd/Zu8BXrY7+DN7D/Cy3cGf2XuAl+0O/szeA7xs
d/Bn9h7gZbuDP7P3AC/bHfyZvQd42e7gz+w9wMt2B39m7wFetjv4M3sP8LLd
wZ/Ze4CX7Q7+zN4DvGx38Gf2HuBlu3PerUPUe6jcCX/wB39yb64Dp0n+KDbX
KWp/OrjadQuKd+rWpZs/ij4Rd3ffUb5Tly7443MDf2Z2wR+fG/gzswv++NzA
n5ld8MfnBv7M7II/Pjeq+HP+FpZEdznSM+t7ZOqi7BNx1+sO/uR6jyxdlH0i
7nrdyeDObmb4k7tPxF3PO/iT6z0ydFH2ibjreSfand3M8Cd3n4i73nfwJ3cH
dRdln4i73nci3dnNDH9y94m4u+MO/uTtoO6i7BNxd8edKHd2M8Of3H0i7u66
gz85O6i7KPtE3N11J8Kd3czwJ3efiLu77kz0x6vXJH92Mqvsz5/eqPq/3bf6
Y+040Z8dzPAnT5db3tqr62R/PJlV9+cSny5dbt3C0d7448MMf3J3ObqFW/vj
jw+zDv6cM6rcxcufayzwx4cZ/uTq4u3PU3+PglNFf44w6+ZP9S6rb310ExH+
VM01fzpF5U+HwCkfM1Jnex064A+J2F6HDrhD1Nvr1AVviGqL0d8NM5Ih7ABm
RLOF6G/NEpiRI1uI/sZsgRm5ZQvR35Y1MCPXthD9XZkDM3JpC9HfUyEwI+db
iP6OSoEZIYSQLvkNijpqOg==
     "], {{0, 151}, {208, 0}}, {0, 255},
     ColorFunction->RGBColor],
    BoxForm`ImageTag[
    "Byte", ColorSpace -> "RGB", Interleaving -> True, MetaInformation -> 
     Association[
      "Comments" -> Association["Comment" -> "Ulead GIF SmartSaver Ver 2.0"]]],
    Selectable->False],
   DefaultBaseStyle->"ImageGraphics",
   ImageSizeRaw->{208, 151},
   PlotRange->{{0, 208}, {0, 151}}]], "Input"],
 "\nHow many such routes are there through a 20\[Times]20 grid?"
}], "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259843286908135`*^9, 
   3.8259843408320274`*^9}, {3.825991995666458*^9, 3.8259920639292836`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"Binomial", "[", 
  RowBox[{"40", ",", "20"}], "]"}]], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.82598433075602*^9, 3.8259843326812124`*^9}, {
   3.8259846976180735`*^9, 3.8259848486700735`*^9}, {3.8259853356165056`*^9, 
   3.8259854803599787`*^9}, {3.825985513039246*^9, 3.8259859767446117`*^9}, {
   3.8259860201459513`*^9, 3.825986028486786*^9}, {3.825986533072239*^9, 
   3.8259865385197835`*^9}, {3.825986585439475*^9, 3.8259867377887087`*^9}, {
   3.825987071597086*^9, 3.825987112588185*^9}, {3.8259871457855043`*^9, 
   3.82598724525245*^9}, 3.825987874354354*^9, {3.825988256832056*^9, 
   3.825988284403056*^9}, {3.825988325538056*^9, 3.825988337872056*^9}, {
   3.82598924276019*^9, 3.8259893025111647`*^9}, {3.825989347262639*^9, 
   3.825989415348447*^9}, {3.825989535096421*^9, 3.8259896330732174`*^9}, {
   3.8259896791318226`*^9, 3.8259897571796265`*^9}, {3.825989832184127*^9, 
   3.8259901532332287`*^9}, {3.825990296691573*^9, 3.8259905787677774`*^9}, {
   3.8259909505469513`*^9, 3.825990995374434*^9}, {3.825991073800276*^9, 
   3.8259910770305986`*^9}, {3.8259911124161367`*^9, 
   3.8259913504229355`*^9}, {3.8259920045823493`*^9, 3.825992004946386*^9}, {
   3.8259921519970894`*^9, 3.8259921626841583`*^9}}],

Cell[BoxData["137846528820"], "Output",
 CellChangeTimes->{3.825992163535243*^9, 3.827013871656581*^9}]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]16. Power digit sum", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.825984319880933*^9, 
   3.8259843237983246`*^9}, {3.8259919776570387`*^9, 3.825991986562039*^9}, {
   3.8259922158264713`*^9, 3.825992217316621*^9}}],

Cell["\<\
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2^1000?\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259843286908135`*^9, 
   3.8259843408320274`*^9}, {3.825991995666458*^9, 3.8259920639292836`*^9}, {
   3.825992225230412*^9, 3.8259922384887376`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{
   SuperscriptBox["2", "1000"], "//", "IntegerDigits"}], "//", 
  "Total"}]], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.82598433075602*^9, 3.8259843326812124`*^9}, {
   3.8259846976180735`*^9, 3.8259848486700735`*^9}, {3.8259853356165056`*^9, 
   3.8259854803599787`*^9}, {3.825985513039246*^9, 3.8259859767446117`*^9}, {
   3.8259860201459513`*^9, 3.825986028486786*^9}, {3.825986533072239*^9, 
   3.8259865385197835`*^9}, {3.825986585439475*^9, 3.8259867377887087`*^9}, {
   3.825987071597086*^9, 3.825987112588185*^9}, {3.8259871457855043`*^9, 
   3.82598724525245*^9}, 3.825987874354354*^9, {3.825988256832056*^9, 
   3.825988284403056*^9}, {3.825988325538056*^9, 3.825988337872056*^9}, {
   3.82598924276019*^9, 3.8259893025111647`*^9}, {3.825989347262639*^9, 
   3.825989415348447*^9}, {3.825989535096421*^9, 3.8259896330732174`*^9}, {
   3.8259896791318226`*^9, 3.8259897571796265`*^9}, {3.825989832184127*^9, 
   3.8259901532332287`*^9}, {3.825990296691573*^9, 3.8259905787677774`*^9}, {
   3.8259909505469513`*^9, 3.825990995374434*^9}, {3.825991073800276*^9, 
   3.8259910770305986`*^9}, {3.8259911124161367`*^9, 
   3.8259913504229355`*^9}, {3.8259920045823493`*^9, 3.825992004946386*^9}, {
   3.8259921519970894`*^9, 3.8259921626841583`*^9}, {3.8259922427691655`*^9, 
   3.825992276162505*^9}}],

Cell[BoxData["1366"], "Output",
 CellChangeTimes->{3.825992163535243*^9, 3.825992257046593*^9, 
  3.8259923497928667`*^9, 3.8270138716915846`*^9}]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]17. Number letter counts", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.825984319880933*^9, 
   3.8259843237983246`*^9}, {3.8259919776570387`*^9, 3.825991986562039*^9}, {
   3.8259922158264713`*^9, 3.825992217316621*^9}, {3.8259925362895145`*^9, 
   3.825992540500936*^9}}],

Cell["\<\
If the numbers 1 to 5 are written out in words: one, two, three, four, five, \
then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
If all the numbers from 1 to 1000 (one thousand) inclusive were written out \
in words, how many letters would be used?
NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and \
forty-two) contains 23 letters and 115 (one hundred and fifteen) contains 20 \
letters. The use of \[OpenCurlyDoubleQuote]and\[CloseCurlyDoubleQuote] when \
writing out numbers is in compliance with British usage.\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259843286908135`*^9, 
   3.8259843408320274`*^9}, {3.825991995666458*^9, 3.8259920639292836`*^9}, {
   3.825992225230412*^9, 3.8259922384887376`*^9}, {3.825992546064492*^9, 
   3.8259925512140074`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"IntegerName", "[", "123", "]"}]], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.82598433075602*^9, 3.8259843326812124`*^9}, {
   3.8259846976180735`*^9, 3.8259848486700735`*^9}, {3.8259853356165056`*^9, 
   3.8259854803599787`*^9}, {3.825985513039246*^9, 3.8259859767446117`*^9}, {
   3.8259860201459513`*^9, 3.825986028486786*^9}, {3.825986533072239*^9, 
   3.8259865385197835`*^9}, {3.825986585439475*^9, 3.8259867377887087`*^9}, {
   3.825987071597086*^9, 3.825987112588185*^9}, {3.8259871457855043`*^9, 
   3.82598724525245*^9}, 3.825987874354354*^9, {3.825988256832056*^9, 
   3.825988284403056*^9}, {3.825988325538056*^9, 3.825988337872056*^9}, {
   3.82598924276019*^9, 3.8259893025111647`*^9}, {3.825989347262639*^9, 
   3.825989415348447*^9}, {3.825989535096421*^9, 3.8259896330732174`*^9}, {
   3.8259896791318226`*^9, 3.8259897571796265`*^9}, {3.825989832184127*^9, 
   3.8259901532332287`*^9}, {3.825990296691573*^9, 3.8259905787677774`*^9}, {
   3.8259909505469513`*^9, 3.825990995374434*^9}, {3.825991073800276*^9, 
   3.8259910770305986`*^9}, {3.8259911124161367`*^9, 
   3.8259913504229355`*^9}, {3.8259920045823493`*^9, 3.825992004946386*^9}, {
   3.8259921519970894`*^9, 3.8259921626841583`*^9}, {3.8259922427691655`*^9, 
   3.825992276162505*^9}, 3.8259925529001756`*^9, {3.825994159591829*^9, 
   3.8259941628791575`*^9}}],

Cell[BoxData["\<\"one hundred twenty\[Hyphen]three\"\>"], "Output",
 CellChangeTimes->{3.825994163794249*^9, 3.827013871718587*^9}]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]18. Maximum path sum I", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.825984319880933*^9, 
   3.8259843237983246`*^9}, {3.8259919776570387`*^9, 3.825991986562039*^9}, {
   3.8259922158264713`*^9, 3.825992217316621*^9}, {3.8259925362895145`*^9, 
   3.825992540500936*^9}, 3.825994491767043*^9, 3.8259946985527196`*^9}],

Cell["\<\
By starting at the top of the triangle below and moving to adjacent numbers \
on the row below, the maximum total from top to bottom is 23.
     3
   7 4
  2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom of the triangle below:
                            75
                          95 64
                        17 47 82
                      18 35 87 10
                    20 04 82 47 65
                  19 01 23 75 03 34
                88 02 77 73 07 63 67
              99 65 04 28 06 16 70 92
            41 41 26 56 83 40 80 70 33
          41 48 72 33 47 32 37 16 94 29
        53 71 44 65 25 43 91 52 97 51 14
      70 11 33 28 77 73 17 78 39 68 17 57
    91 71 52 38 17 14 91 43 58 50 27 29 48
  63 66 04 68 89 53 67 30 73 16 69 87 40 31
04 62 98 27 23 09 70 98 73 93 38 53 60 04 23
NOTE: As there are only 16384 routes, it is possible to solve this problem by \
trying every route. However, Problem 67, is the same challenge with a \
triangle containing one-hundred rows; it cannot be solved by brute force, and \
requires a clever method! ;o)
\:5206\:6790
     1
    9 1    \:6700\:5e95\:5c42\:4e0d\:4e00\:5b9a\:9009\:6700\:5927
  1 2 3
     1
    2 1     \:7b2c\:4e8c\:5c42\:4e0d\:4e00\:5b9a\:9009\:6700\:5927
  1 1  9
     5
    5 1     \:4e0d\:4e00\:5b9a\:7ecf\:8fc7\:6574\:4e2a\:6811\:6700\:5927\:70b9
  5 1  9
  \:6700\:540e\:601d\:8def\:ff1a\:4ece\:4e0b\:5f80\:4e0a\:5206\:6790\:3002\
\:4ece\:9876\:70b9\:51fa\:53d1\:4e0d\:7ba1\:9014\:4e2d\:7ecf\:8fc7\:4e86\:4ec0\
\:4e48\:70b9\:6700\:540e\:90fd\:4f1a\:5728\:5012\:6570\:7b2c2\:5c42\:505a\
\:51fa\:9009\:62e9\:ff0c\:800c\:5bf9\:4e8e\:5012\:6570\:7b2c\:4e8c\:5c42\:7684\
\:6bcf\:79cd\:60c5\:51b5\:ff0c\:9009\:62e9\:662f\:660e\:786e\:7684
  \:4e3e\:4f8b\:6765\:8bf4\:ff0c\:5982\:679c\:5012\:6570\:7b2c2\:5c42\:7ecf\
\:8fc766\:ff0c\:90a3\:4e48\:63a5\:4e0b\:6765\:53ea\:80fd\:900998\:ff0c\:5982\
\:679c\:7b2c\:4e8c\:5c42\:7ecf\:8fc763\:ff0c\:5219\:63a5\:4e0b\:6765\:53ea\
\:80fd\:900962
  \:6240\:4ee5\:628a62+63\:5199\:523063\:7684\:4f4d\:7f6e\:ff0c\:628a66+98\
\:5199\:523066\:7684\:4f4d\:7f6e....\:8fd9\:6837\:5c31\:53bb\:6389\:4e86\:6700\
\:540e\:4e00\:5c42\:3002\:5982\:6b64\:5f80\:590d\:76f4\:5230\:8ba1\:7b97\:5230\
\:6811\:6839\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259843286908135`*^9, 
   3.8259843408320274`*^9}, {3.825991995666458*^9, 3.8259920639292836`*^9}, {
   3.825992225230412*^9, 3.8259922384887376`*^9}, {3.825992546064492*^9, 
   3.8259925512140074`*^9}, {3.8259944991147776`*^9, 
   3.8259945885137167`*^9}, {3.8270135049519143`*^9, 
   3.8270135452009387`*^9}, {3.8270135859130096`*^9, 
   3.8270136197403917`*^9}, {3.827014061673581*^9, 3.8270141142058334`*^9}, {
   3.8270209950088544`*^9, 3.827021007851138*^9}, {3.827029569925211*^9, 
   3.827029832641553*^9}, {3.827029878489137*^9, 3.827029883782666*^9}, {
   3.827029940877375*^9, 3.827029959714259*^9}, {3.8270301035636425`*^9, 
   3.827030136735959*^9}, {3.827030354496733*^9, 3.8270304770849905`*^9}, {
   3.827030522862568*^9, 3.827030623332614*^9}, {3.8270306623805184`*^9, 
   3.827030663416622*^9}, {3.8270308178440633`*^9, 3.827030839895268*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{"StringCases", "[", 
   RowBox[{"\"\<95 64\>\"", ",", 
    RowBox[{"DigitCharacter", ".."}]}], "]"}], "//", "ToExpression", 
  RowBox[{"(*", 
   RowBox[{"\:9884\:5904\:7406", "\:ff0c", "\:5148\:8f6c\:6210\:5217\:8868"}],
    "*)"}]}]], "Input",
 CellChangeTimes->{{3.827033750021261*^9, 3.827033945303787*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"95", ",", "64"}], "}"}]], "Output",
 CellChangeTimes->{{3.8270337716344223`*^9, 3.8270339463858957`*^9}}]
}, Open  ]],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"FindMaxRoute", "[", "list_", "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"temp", ",", 
       RowBox[{"listCopy", " ", "=", " ", "list"}]}], "}"}], ",", "\n", 
     RowBox[{
      RowBox[{"For", "[", 
       RowBox[{
        RowBox[{"i", "=", "1"}], ",", 
        RowBox[{"i", "\[LessEqual]", 
         RowBox[{"Length", "@", "listCopy"}]}], ",", 
        RowBox[{"i", "++"}], ",", "\n", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"i", ">", "1"}], ",", "\n", 
           RowBox[{
            RowBox[{"temp", " ", "=", " ", 
             RowBox[{"{", "}"}]}], ";", "\n", 
            RowBox[{"For", "[", 
             RowBox[{
              RowBox[{"j", "=", "1"}], ",", 
              RowBox[{"j", "\[LessEqual]", 
               RowBox[{"Length", "@", 
                RowBox[{
                "listCopy", "\[LeftDoubleBracket]", "i", 
                 "\[RightDoubleBracket]"}]}]}], ",", 
              RowBox[{"j", "++"}], ",", "\n", "\t", 
              RowBox[{
               RowBox[{"AppendTo", "[", 
                RowBox[{"temp", ",", 
                 RowBox[{
                  RowBox[{
                   RowBox[{
                   "listCopy", "\[LeftDoubleBracket]", "i", 
                    "\[RightDoubleBracket]"}], "\[LeftDoubleBracket]", "j", 
                   "\[RightDoubleBracket]"}], "+", 
                  RowBox[{"Max", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"listCopy", "\[LeftDoubleBracket]", 
                    RowBox[{"i", "-", "1"}], "\[RightDoubleBracket]"}], 
                    "\[LeftDoubleBracket]", "j", "\[RightDoubleBracket]"}], 
                    ",", 
                    RowBox[{
                    RowBox[{"listCopy", "\[LeftDoubleBracket]", 
                    RowBox[{"i", "-", "1"}], "\[RightDoubleBracket]"}], 
                    "\[LeftDoubleBracket]", 
                    RowBox[{"j", "+", "1"}], "\[RightDoubleBracket]"}]}], 
                   "]"}]}]}], "]"}], ";"}]}], "\n", "]"}], ";", "\n", 
            RowBox[{
             RowBox[{
             "listCopy", "\[LeftDoubleBracket]", "i", 
              "\[RightDoubleBracket]"}], "=", "temp"}], ";"}]}], "\n", "]"}], 
         ";"}]}], "]"}], ";", "\n", 
      RowBox[{"listCopy", "//", "Last"}]}]}], "\n", "]"}]}], ";"}], "\n", 
 RowBox[{"FindMaxRoute", "[", 
  RowBox[{"{", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{
     "04", ",", "62", ",", "98", ",", "27", ",", "23", ",", "09", ",", "70", 
      ",", "98", ",", "73", ",", "93", ",", "38", ",", "53", ",", "60", ",", 
      "04", ",", "23"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{
     "63", ",", "66", ",", "4", ",", "68", ",", "89", ",", "53", ",", "67", 
      ",", "30", ",", "73", ",", "16", ",", "69", ",", "87", ",", "40", ",", 
      "31"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{
     "91", ",", "71", ",", "52", ",", "38", ",", "17", ",", "14", ",", "91", 
      ",", "43", ",", "58", ",", "50", ",", "27", ",", "29", ",", "48"}], 
     "}"}], ",", "\n", 
    RowBox[{"{", 
     RowBox[{
     "70", ",", "11", ",", "33", ",", "28", ",", "77", ",", "73", ",", "17", 
      ",", "78", ",", "39", ",", "68", ",", "17", ",", "57"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{
     "53", ",", "71", ",", "44", ",", "65", ",", "25", ",", "43", ",", "91", 
      ",", "52", ",", "97", ",", "51", ",", "14"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{
     "41", ",", "48", ",", "72", ",", "33", ",", "47", ",", "32", ",", "37", 
      ",", "16", ",", "94", ",", "29"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{
     "41", ",", "41", ",", "26", ",", "56", ",", "83", ",", "40", ",", "80", 
      ",", "70", ",", "33"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{
     "99", ",", "65", ",", "4", ",", "28", ",", "6", ",", "16", ",", "70", 
      ",", "92"}], "}"}], ",", "\n", 
    RowBox[{"{", 
     RowBox[{
     "88", ",", "2", ",", "77", ",", "73", ",", "7", ",", "63", ",", "67"}], 
     "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"19", ",", "1", ",", "23", ",", "75", ",", "3", ",", "34"}], 
     "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"20", ",", "4", ",", "82", ",", "47", ",", "65"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"18", ",", "35", ",", "87", ",", "10"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"17", ",", "47", ",", "82"}], "}"}], ",", 
    RowBox[{"{", 
     RowBox[{"95", ",", "64"}], "}"}], ",", 
    RowBox[{"{", "75", "}"}]}], "}"}], "]"}]}], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.82598433075602*^9, 3.8259843326812124`*^9}, {
   3.8259846976180735`*^9, 3.8259848486700735`*^9}, {3.8259853356165056`*^9, 
   3.8259854803599787`*^9}, {3.825985513039246*^9, 3.8259859767446117`*^9}, {
   3.8259860201459513`*^9, 3.825986028486786*^9}, {3.825986533072239*^9, 
   3.8259865385197835`*^9}, {3.825986585439475*^9, 3.8259867377887087`*^9}, {
   3.825987071597086*^9, 3.825987112588185*^9}, {3.8259871457855043`*^9, 
   3.82598724525245*^9}, 3.825987874354354*^9, {3.825988256832056*^9, 
   3.825988284403056*^9}, {3.825988325538056*^9, 3.825988337872056*^9}, {
   3.82598924276019*^9, 3.8259893025111647`*^9}, {3.825989347262639*^9, 
   3.825989415348447*^9}, {3.825989535096421*^9, 3.8259896330732174`*^9}, {
   3.8259896791318226`*^9, 3.8259897571796265`*^9}, {3.825989832184127*^9, 
   3.8259901532332287`*^9}, {3.825990296691573*^9, 3.8259905787677774`*^9}, {
   3.8259909505469513`*^9, 3.825990995374434*^9}, {3.825991073800276*^9, 
   3.8259910770305986`*^9}, {3.8259911124161367`*^9, 
   3.8259913504229355`*^9}, {3.8259920045823493`*^9, 3.825992004946386*^9}, {
   3.8259921519970894`*^9, 3.8259921626841583`*^9}, {3.8259922427691655`*^9, 
   3.825992276162505*^9}, 3.8259925529001756`*^9, {3.825994159591829*^9, 
   3.8259941628791575`*^9}, 3.8259945096348295`*^9, {3.8270138408545012`*^9, 
   3.8270138645228677`*^9}, {3.8270139005264673`*^9, 
   3.8270139252889433`*^9}, {3.8270140053369474`*^9, 
   3.8270140060390177`*^9}, {3.827014487330142*^9, 3.8270146076651745`*^9}, {
   3.8270146565990677`*^9, 3.8270146762910366`*^9}, {3.827015132559659*^9, 
   3.827015180304433*^9}, {3.827015329898391*^9, 3.827015336643065*^9}, {
   3.827015407749175*^9, 3.8270154140948095`*^9}, {3.827015634652863*^9, 
   3.8270158532917247`*^9}, {3.8270159276871634`*^9, 
   3.8270159287572703`*^9}, {3.8270202405184126`*^9, 
   3.8270202580241632`*^9}, {3.827020331018462*^9, 3.8270203754369035`*^9}, {
   3.827020462382597*^9, 3.82702048060942*^9}, {3.827020525100868*^9, 
   3.827020597596117*^9}, {3.827020937202074*^9, 3.8270209648388376`*^9}, {
   3.8270210152918825`*^9, 3.827021064329786*^9}, {3.8270211025126038`*^9, 
   3.8270211026516175`*^9}, {3.8270229568300266`*^9, 
   3.8270230419705396`*^9}, {3.8270231841437554`*^9, 3.827023282618602*^9}, {
   3.8270233146958094`*^9, 3.8270233282101603`*^9}, {3.8270236744517813`*^9, 
   3.827023722465582*^9}, {3.827025707880104*^9, 3.8270257709242287`*^9}, {
   3.82702808928623*^9, 3.827028183509651*^9}, {3.827028219079208*^9, 
   3.827028294839783*^9}, 3.827030489458228*^9, {3.827030925770855*^9, 
   3.8270309744067183`*^9}, {3.8270310472940063`*^9, 3.827031053415618*^9}, {
   3.827031088820158*^9, 3.82703109093937*^9}, {3.827031402721545*^9, 
   3.827031485259798*^9}, {3.8270316989461646`*^9, 3.8270317019224625`*^9}, {
   3.8270317594692163`*^9, 3.8270317852817974`*^9}, {3.8270318472689953`*^9, 
   3.827031849354204*^9}, {3.8270325825485163`*^9, 3.827032644885749*^9}, {
   3.827032676916952*^9, 3.8270330086841927`*^9}, {3.8270331066741924`*^9, 
   3.8270334450641923`*^9}, {3.827033541130374*^9, 3.8270335472449856`*^9}, 
   3.8270337352207813`*^9, {3.8270337837516336`*^9, 3.8270339901792746`*^9}}],

Cell[BoxData[
 RowBox[{"{", "1074", "}"}]], "Output",
 CellChangeTimes->{{3.827033963215578*^9, 3.827033991206377*^9}}]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]19. Counting Sundays", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.825984319880933*^9, 
   3.8259843237983246`*^9}, {3.8259919776570387`*^9, 3.825991986562039*^9}, {
   3.8259922158264713`*^9, 3.825992217316621*^9}, {3.8259925362895145`*^9, 
   3.825992540500936*^9}, {3.8259947081906834`*^9, 3.825994712733137*^9}}],

Cell["\<\
You are given the following information, but you may prefer to do some \
research for yourself.
   1 Jan 1900 was a Monday.
    Thirty days has September,
    \tApril, June and November.
   \t All the rest have thirty-one,
    \tSaving February alone,
    \tWhich has twenty-eight, rain or shine.
   \t And on leap years, twenty-nine.
    A leap year occurs on any year evenly divisible by 4, but not on a \
century unless it is divisible by 400.
How many Sundays fell on the first of the month during the twentieth century \
(1 Jan 1901 to 31 Dec 2000)?\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259843286908135`*^9, 
   3.8259843408320274`*^9}, {3.825991995666458*^9, 3.8259920639292836`*^9}, {
   3.825992225230412*^9, 3.8259922384887376`*^9}, {3.825992546064492*^9, 
   3.8259925512140074`*^9}, {3.8259947188847523`*^9, 3.825994749890853*^9}}],

Cell[BoxData[""], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.82598433075602*^9, 3.8259843326812124`*^9}, {
   3.8259846976180735`*^9, 3.8259848486700735`*^9}, {3.8259853356165056`*^9, 
   3.8259854803599787`*^9}, {3.825985513039246*^9, 3.8259859767446117`*^9}, {
   3.8259860201459513`*^9, 3.825986028486786*^9}, {3.825986533072239*^9, 
   3.8259865385197835`*^9}, {3.825986585439475*^9, 3.8259867377887087`*^9}, {
   3.825987071597086*^9, 3.825987112588185*^9}, {3.8259871457855043`*^9, 
   3.82598724525245*^9}, 3.825987874354354*^9, {3.825988256832056*^9, 
   3.825988284403056*^9}, {3.825988325538056*^9, 3.825988337872056*^9}, {
   3.82598924276019*^9, 3.8259893025111647`*^9}, {3.825989347262639*^9, 
   3.825989415348447*^9}, {3.825989535096421*^9, 3.8259896330732174`*^9}, {
   3.8259896791318226`*^9, 3.8259897571796265`*^9}, {3.825989832184127*^9, 
   3.8259901532332287`*^9}, {3.825990296691573*^9, 3.8259905787677774`*^9}, {
   3.8259909505469513`*^9, 3.825990995374434*^9}, {3.825991073800276*^9, 
   3.8259910770305986`*^9}, {3.8259911124161367`*^9, 
   3.8259913504229355`*^9}, {3.8259920045823493`*^9, 3.825992004946386*^9}, {
   3.8259921519970894`*^9, 3.8259921626841583`*^9}, {3.8259922427691655`*^9, 
   3.825992276162505*^9}, 3.8259925529001756`*^9, {3.825994159591829*^9, 
   3.8259941628791575`*^9}, 3.825994932508113*^9}]
}, Open  ]],

Cell[CellGroupData[{

Cell["\[FilledSquare]20. Factorial digit sum", "Subsubsection",
 CellChangeTimes->{
  3.825800627408572*^9, {3.82582672752663*^9, 3.82582672891463*^9}, {
   3.8259759994609547`*^9, 3.825976009090918*^9}, {3.825984319880933*^9, 
   3.8259843237983246`*^9}, {3.8259919776570387`*^9, 3.825991986562039*^9}, {
   3.8259922158264713`*^9, 3.825992217316621*^9}, {3.8259925362895145`*^9, 
   3.825992540500936*^9}, {3.8259947081906834`*^9, 3.825994712733137*^9}, {
   3.8259949636902304`*^9, 3.8259949695988216`*^9}}],

Cell["\<\
n! means n \[Times] (n \[Minus] 1) \[Times] ... \[Times] 3 \[Times] 2 \
\[Times] 1
For example, 10! = 10 \[Times] 9 \[Times] ... \[Times] 3 \[Times] 2 \[Times] \
1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits in the number 100!\
\>", "Text",
 CellChangeTimes->{
  3.8258006477536063`*^9, {3.82582673603463*^9, 3.825826757736405*^9}, {
   3.825976016777686*^9, 3.8259760254095497`*^9}, {3.8259843286908135`*^9, 
   3.8259843408320274`*^9}, {3.825991995666458*^9, 3.8259920639292836`*^9}, {
   3.825992225230412*^9, 3.8259922384887376`*^9}, {3.825992546064492*^9, 
   3.8259925512140074`*^9}, {3.8259947188847523`*^9, 3.825994749890853*^9}, {
   3.8259949751883802`*^9, 3.825994979445806*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"100", "!"}], "//", "IntegerDigits"}], "//", "Total"}]], "Code",
 CellChangeTimes->{
  3.825800668543685*^9, {3.825826767317363*^9, 3.8258268038500156`*^9}, {
   3.8258269278914185`*^9, 3.825826936535283*^9}, {3.825827022094838*^9, 
   3.825827034247053*^9}, 3.8259760345894675`*^9, {3.825976503093313*^9, 
   3.8259766447044725`*^9}, {3.8259767455865602`*^9, 3.825976754194421*^9}, {
   3.825976786454646*^9, 3.8259767889929004`*^9}, {3.8259769723712363`*^9, 
   3.8259770523902373`*^9}, {3.82598433075602*^9, 3.8259843326812124`*^9}, {
   3.8259846976180735`*^9, 3.8259848486700735`*^9}, {3.8259853356165056`*^9, 
   3.8259854803599787`*^9}, {3.825985513039246*^9, 3.8259859767446117`*^9}, {
   3.8259860201459513`*^9, 3.825986028486786*^9}, {3.825986533072239*^9, 
   3.8259865385197835`*^9}, {3.825986585439475*^9, 3.8259867377887087`*^9}, {
   3.825987071597086*^9, 3.825987112588185*^9}, {3.8259871457855043`*^9, 
   3.82598724525245*^9}, 3.825987874354354*^9, {3.825988256832056*^9, 
   3.825988284403056*^9}, {3.825988325538056*^9, 3.825988337872056*^9}, {
   3.82598924276019*^9, 3.8259893025111647`*^9}, {3.825989347262639*^9, 
   3.825989415348447*^9}, {3.825989535096421*^9, 3.8259896330732174`*^9}, {
   3.8259896791318226`*^9, 3.8259897571796265`*^9}, {3.825989832184127*^9, 
   3.8259901532332287`*^9}, {3.825990296691573*^9, 3.8259905787677774`*^9}, {
   3.8259909505469513`*^9, 3.825990995374434*^9}, {3.825991073800276*^9, 
   3.8259910770305986`*^9}, {3.8259911124161367`*^9, 
   3.8259913504229355`*^9}, {3.8259920045823493`*^9, 3.825992004946386*^9}, {
   3.8259921519970894`*^9, 3.8259921626841583`*^9}, {3.8259922427691655`*^9, 
   3.825992276162505*^9}, 3.8259925529001756`*^9, {3.825994159591829*^9, 
   3.8259941628791575`*^9}, 3.825994932508113*^9, {3.8259949888177433`*^9, 
   3.8259949996228237`*^9}}],

Cell[BoxData["648"], "Output",
 CellChangeTimes->{3.825995000016863*^9, 3.827013871809596*^9}]
}, Open  ]]
}, Open  ]]
}, Open  ]]
},
WindowToolbars->"EditBar",
WindowSize->{1600, 826},
WindowMargins->{{-8, Automatic}, {Automatic, -8}},
CellContext->Notebook,
Magnification:>1.3 Inherited,
FrontEndVersion->"11.0 for Microsoft Windows (64-bit) (2016\:5e7410\:67088\
\:65e5)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[580, 22, 152, 3, 117, "Title"],
Cell[CellGroupData[{
Cell[757, 29, 158, 2, 43, "Subsubsection"],
Cell[918, 33, 436, 9, 89, "Text"],
Cell[1357, 44, 1571, 24, 546, "Code"],
Cell[CellGroupData[{
Cell[2953, 72, 3682, 110, 210, "Code"],
Cell[6638, 184, 381, 6, 39, "Output"],
Cell[7022, 192, 378, 6, 39, "Output"],
Cell[7403, 200, 381, 6, 39, "Output"],
Cell[7787, 208, 379, 6, 39, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[8215, 220, 219, 3, 43, "Subsubsection"],
Cell[8437, 225, 720, 19, 313, "Text"],
Cell[CellGroupData[{
Cell[9182, 248, 1732, 41, 213, "Code"],
Cell[10917, 291, 129, 2, 39, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[11095, 299, 246, 4, 43, "Subsubsection"],
Cell[11344, 305, 261, 4, 39, "Text"]
}, Open  ]],
Cell[CellGroupData[{
Cell[11642, 314, 261, 4, 43, "Subsubsection"],
Cell[11906, 320, 945, 17, 239, "Text"],
Cell[CellGroupData[{
Cell[12876, 341, 4194, 97, 426, "Code"],
Cell[17073, 440, 259, 5, 39, "Output"],
Cell[17335, 447, 309, 7, 39, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[17693, 460, 298, 4, 43, "Subsubsection"],
Cell[17994, 466, 2960, 55, 260, "Text"],
Cell[CellGroupData[{
Cell[20979, 525, 1647, 24, 65, "Code"],
Cell[22629, 551, 103, 1, 39, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[22781, 558, 352, 5, 43, "Subsubsection"],
Cell[23136, 565, 439, 8, 64, "Text"],
Cell[CellGroupData[{
Cell[23600, 577, 1734, 27, 65, "Code"],
Cell[25337, 606, 146, 2, 39, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[25532, 614, 409, 6, 43, "Subsubsection"],
Cell[25944, 622, 923, 15, 114, "Text"],
Cell[CellGroupData[{
Cell[26892, 641, 1755, 25, 65, "Code"],
Cell[28650, 668, 131, 1, 39, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[28830, 675, 453, 6, 43, "Subsubsection"],
Cell[29286, 683, 3272, 66, 936, "Text"],
Cell[CellGroupData[{
Cell[32583, 753, 344, 8, 59, "Input"],
Cell[32930, 763, 145, 3, 39, "Output"]
}, Open  ]],
Cell[CellGroupData[{
Cell[33112, 771, 8176, 163, 378, "Code"],
Cell[41291, 936, 119, 2, 39, "Output"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[41459, 944, 453, 6, 43, "Subsubsection"],
Cell[41915, 952, 976, 20, 264, "Text"],
Cell[42894, 974, 1737, 24, 65, "Code"]
}, Open  ]],
Cell[CellGroupData[{
Cell[44668, 1003, 510, 7, 43, "Subsubsection"],
Cell[45181, 1012, 773, 14, 114, "Text"],
Cell[CellGroupData[{
Cell[45979, 1030, 1876, 28, 65, "Code"],
Cell[47858, 1060, 94, 1, 39, "Output"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
}
]
*)

